package image;

import java.awt.Image;
import java.awt.MediaTracker;
import java.util.HashMap;

import javax.swing.ImageIcon;

public class ImageTable{
	private static HashMap<Object, Image> IMAGES = new HashMap<Object, Image>(30);
	public static Image get(Object obj){
		Image image = IMAGES.get(obj);
		if(image == null){
			image = getImage(obj);
			IMAGES.put(obj, image);
		}
		
		return image;
	}
	
	public static Image getImage(Object obj){
		System.out.println(obj);
		ImageIcon img = new ImageIcon("images/" + obj.toString() + ".gif");
		if(img.getImageLoadStatus() != MediaTracker.COMPLETE){
			return null;
		}
		
		return img.getImage();
	}
}
